import QtQuick
import QtQuick.Layouts
import QtCharts

Rectangle {
    Layout.fillWidth: true
    Layout.fillHeight: true

    ChartView {
        id: chartView
        title: "水平柱形图示例"
        titleFont.bold: true
        titleFont.pointSize: 14

        anchors.fill: parent
        antialiasing: true

        BarCategoryAxis {
            id: valueAxisY
            categories: ["6月", "7月", "8月", "9月"]
            titleText: "月份"
        }

        ValueAxis {
            id: valueAxisX
            min: 0
            max: 20
            titleText: "数量"
        }

        HorizontalBarSeries {
            name: "柱形图"
            axisX: valueAxisX
            axisY: valueAxisY

            labelsVisible: true
            labelsFormat: "@value"
            labelsPosition: AbstractBarSeries.LabelsOutsideEnd

            BarSet {
                // 图例名
                label: "bar1"

                // 背景图
                brushFilename: ":/images/bg1.png"

                // 柱形图数值标签
                labelColor: "#333"
                labelFont.family: "Courier"
                labelFont.bold: true
                labelFont.pointSize: 10

                // 边框属性
                borderColor: "#F0F0F0"
                borderWidth: 1

                // 数值
                values: [7.52, 9.21, 12.3, 8.8]
            }
            BarSet {
                label: "bar2"
                color : "#FF9612"
                labelColor: "#333"
                values: [15.12, 7.34, 10.5, 15.6]
            }
            BarSet {
                label: "bar3"
                color : "#12FF96"
                labelColor: "#333"
                values: [10.43, 9.64, 12.3, 18.5]
            }
        }
    }
}
